package vip.fuxk.blog.config;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import org.noear.luffy.executor.ExecutorFactory;
import org.noear.snack.ONode;
import org.noear.solon.Solon;
import org.noear.solon.SolonApp;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.EventListener;
import org.noear.solon.core.handle.Filter;
import org.noear.wood.DbContext;
import vip.fuxk.blog.service.DataService;
import vip.fuxk.blog.utils.DateKit;
import vip.fuxk.blog.utils.JsonKit;
import vip.fuxk.blog.utils.PropKit;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class  AppLoadEndEventListener implements EventListener<AppLoadEndEvent> {

    @Inject
    private DataService dataService;

    @Inject
    private DateKit dateKit;

    @Inject
    private JsonKit jsonKit;

    @Override
    public void onEvent(AppLoadEndEvent event) throws Throwable {
        //获取应用对象
        SolonApp app = event.app();
        app.sharedAdd("db", DbContext.use("blog_main"));
        app.sharedAdd("dq",dataService);
        app.sharedAdd("DateKit", dateKit);
        app.sharedAdd("jsonKit", jsonKit);
//        app.context().wrapAndPut(Filter.class,new AppFilter());
    }
}